package com.siblings.loan.ui.tab.adapter

import android.graphics.Color
import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView
import com.siblings.lib_baseadapter.SIBRecyclerViewAdapter
import com.siblings.lib_baseadapter.SIBViewHolderHelper
import com.siblings.loan.R
import org.json.JSONObject

/**
 * SiblingsLoan
 * @Author wwdeng
 * @CreateTime: 2024/7/8 16:42
 * @Annotation：Tab适配器
 */

class SibTabAdapter(recyclerView: RecyclerView?) : SIBRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_tab) {
    override fun setItemChildListener(helper: SIBViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }

    override fun fillData(helper: SIBViewHolderHelper, position: Int, model: JSONObject) {
        val isSelect = model.optBoolean("isSelect", false)
        val imgTab = helper.getImageView(R.id.imgTab)
        val textTab = helper.getTextView(R.id.textTab)

        textTab.text = model.optString("tabTitle")
        when(isSelect){
            true -> {
                textTab.setTextColor(Color.parseColor("#FF4DB673"))
                imgTab.setImageResource(model.optInt("tabImageSelect"))
            }
            else -> {
                textTab.setTextColor(Color.parseColor("#FFADB4CC"))
                imgTab.setImageResource(model.optInt("tabImageNormal"))
            }
        }
    }
}